package com.xlh.server.protocol.support.json;

import android.graphics.Color;
import android.text.Html;
import android.text.method.LinkMovementMethod;

import com.xlh.Utils.Constant;
import com.xlh.Utils.FontHandler;
import com.xlh.Utils.GsonManager;
import com.xlh.bean.ProtocolObject.RoomDesc;
import com.xlh.interf.IActivity;
import com.xlh.interf.ITakeMessage;

import net.nightwhistler.htmlspanner.HtmlSpanner;

/**
 * Created by Administrator on 2018/7/2.
 */

public class RoomDescServer implements ITakeMessage {

    private IActivity atv;
    private String hasType = "roomDesc";
    private RoomDesc protccoObj;
    public RoomDescServer(IActivity atv){
        this.atv = atv;


    }

    @Override
    public void takeMessage(String t,String s){

        if(!t.equals(this.hasType)) return;

        protccoObj =  GsonManager.gsmgr.jsonToAnyObject(s, RoomDesc.class);

        if(protccoObj==null) return;

        final RoomDescServer me = this;
        String text;

        this.atv.getActivity().tvContent.setTextColor(Color.parseColor(Constant.getAppColor().getFontColor()));
       // FontHandler htmlHandlerChatList = new FontHandler(this.atv.getActivity());

       // this.atv.getActivity().tvContent.setText(Html.fromHtml(protccoObj.getText(), null, htmlHandlerChatList));
        this.atv.getActivity().tvContent.setText( this.atv.getActivity().getHtmlSpanner().fromHtml(protccoObj.getText()));
        this.atv.getActivity().tvContent.setClickable(true);
        this.atv.getActivity().tvContent.setMovementMethod(LinkMovementMethod.getInstance());



    }

    @Override
    public boolean takeMessage(String s) {
        return false;
    }

    @Override
    public void init() {

    }

    @Override
    public void atViewLoadAfterInit() {

    }

}
